import request from "@/request";
import ResultEnum from "@/config/ResultEnum";
import { message } from "ant-design-vue";

export interface FormValue {
  userId: string | undefined;
  userName: string | undefined;
  realName: string | undefined;
  nickName: string | undefined;
  deptId: string | undefined;
  roleId: string | undefined;
  email: string | undefined;
  phone: string | undefined;
  sex: string | undefined;
  avatar: string | undefined;
  status: string | undefined;
  remark: string | undefined;
}

export const statusOptions = [
  {
    label: "正常",
    value: "Normal",
    color: "#2db7f5",
  },
  {
    label: "禁用",
    value: "Disable",
    color: "#87d068",
  },
];

export const submit = (data: any) => {
  return new Promise((resolve: any, reject: any) => {
    request({
      url: "/user/update",
      method: "post",
      data,
    }).then((res: any) => {
      if (res.code == ResultEnum.SUCCESS_CODE) {
        resolve(res.result);
      } else {
        reject(res.message);
      }
    });
  });
};

export const detail = (id: string) => {
  return new Promise((resolve: any, reject: any) => {
    request({
      url: "/user/" + id,
      method: "get",
    }).then((res: any) => {
      if (res.code == ResultEnum.SUCCESS_CODE) {
        resolve(res.result);
      } else {
        reject(res.message);
      }
    });
  });
};
